package com.fundboss.display;

import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import model.market.FinanceCharges;
import model.market.MarketConfig;

public class AdvancedParamPanel  extends JPanel {

	
	public AdvancedParamPanel(final MarketConfig config){
		setLayout(new GridLayout(0,2));
		JLabel title = new JLabel("Advanced");
		title.setFont(new Font("Arial",Font.BOLD,18));
		add(title);
		add(new JLabel(""));
		
		add(new JLabel("Beta adjustment"));
		final JComboBox beta = new JComboBox(new Object[]{MarketConfig.BETA_UNADJUSTED,MarketConfig.BETA_STD_ERR,MarketConfig.BETA_BLOOMBERG,MarketConfig.BETA_FIXED});
		beta.setSelectedItem(MarketConfig.BETA_FIXED);
		config.setBetaCalculation(MarketConfig.BETA_FIXED);
		add(beta);
		beta.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				String option = (String) beta.getSelectedItem();
				config.setBetaCalculation(option);
			}
		});
		
		
		//constraints.gridwidth=GridBagConstraints.RELATIVE;
		add(new JLabel("Trader finance charge"));//,constraints);
		final JComboBox financeCharge = new JComboBox(new Object[]{FinanceCharges.NONE,
				FinanceCharges.RF,
				FinanceCharges.BETA_MKT,
				FinanceCharges.MKT,
				FinanceCharges.BETA_ERP});
		//add(new JLabel());//
		//constraints.gridwidth=GridBagConstraints.REMAINDER;
		add(financeCharge);
		financeCharge.setSelectedItem(FinanceCharges.RF);
		config.setFinanceCharge(FinanceCharges.RF);
		
		financeCharge.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				FinanceCharges selected = (FinanceCharges) financeCharge.getSelectedItem();
				config.setFinanceCharge(selected);
				
			}
		});
		
		
	}
}
